package com.anlu.alspringmvc.demo.action;


import com.anlu.alspringmvc.demo.service.IQueryService;
import com.anlu.alspringmvc.spring.framework.annotation.ALController;
import com.anlu.alspringmvc.spring.framework.annotation.ALRequestMapping;
import com.anlu.alspringmvc.spring.framework.annotation.ALRequestParam;
import com.anlu.alspringmvc.spring.framework.webmvc.servlet.ALModelAndView;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

@ALController
@ALRequestMapping(value = "/")
public class PageAction {


    @Autowired
    IQueryService queryService;

    @ALRequestMapping("/first.html")
    public ALModelAndView query(@ALRequestParam("teacher") String teacher){
        String result = queryService.query(teacher);
        Map<String,Object> model = new HashMap<String,Object>();
        model.put("teacher", teacher);
        model.put("data", result);
        model.put("token", "123456");
        return new ALModelAndView("first.html",model);
    }

}
